var app = getApp()
var city = require('../../../../utils/city.js');
Page({
  data: {
    currentCity: '定位中...',
    letterArr: [],
    city1: []
  },
  onLoad: function (options) {
    var that = this
    // wx.setNavigationBarColor({
    //       frontColor: wx.getStorageSync("color"),
    //       backgroundColor: wx.getStorageSync("bcolor"),
    // })
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    var currentCity = wx.getStorageSync("city");
    that.setData({
      currentCity: currentCity
    })
    that.getCity();
    var searchLetter = city.searchLetter;
    var cityList = city.cityList();
    var city1 = cityList
    var letterArr = searchLetter
    that.setData({
      city1: city1,
      letterArr: letterArr,
    })
  },
  // 热门城市
  getCity: function () {
    var that = this;
    app.util.request({
      'url': 'entry/wxapp/Remencity',
      success: function (res) {
        console.log(res)
        that.setData({
          info: res.data.data,
        });
      },
    })
  },

  //选择城市
  confirmClick: function (e) {
    var a_id = e.target.dataset.a_id;
    console.log(a_id);
    wx.setStorage({
      key: 'city',
      data: a_id,
    })
    var reg = new RegExp('[\u4e00-\u9fa5]+', 'g')
    if (!a_id.search(reg)) {
      console.log(e.target.dataset.a_id);
      wx.setStorageSync('city', e.target.dataset.a_id);
      wx.switchTab({
        url: '/hyb_yl/tabBar/index/index',
      })
    }
  },
  //锚点跳转
  anchorClick: function (e) {
    var that = this
    var a_id = e.currentTarget.dataset.a_id;
    that.setData({
      toView: a_id
    })
  },
})    